home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / hips / sources / scale_geom / window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-17  |  1.6 KB  |  83 lines

  1.  
  2. #include "simple.h"
  3. #include "window.h"
  4.  
  5. static char rcsid[] = "$Header: window.c,v 2.0 88/10/10 13:46:29 ph Locked $";
  6.  
  7. window_set(x0, y0, x1, y1, a)
  8. int x0, y0, x1, y1;
  9. register Window *a;
  10. {
  11.     a->x0 = x0;
  12.     a->y0 = y0;
  13.     a->x1 = x1;
  14.     a->y1 = y1;
  15. }
  16.  
  17. window_clip(a, b)        /* a=intersect(a,b), return overlap bit */
  18. register Window *a, *b;
  19. {
  20.     int overlap;
  21.  
  22.     overlap = window_overlap(a, b);
  23.     window_intersect(a, b, a);
  24.     return overlap;
  25. }
  26.  
  27. window_intersect(a, b, c)    /* c = intersect(a,b) */
  28. register Window *a, *b, *c;
  29. {
  30.     c->x0 = MAX(a->x0, b->x0);
  31.     c->y0 = MAX(a->y0, b->y0);
  32.     c->x1 = MIN(a->x1, b->x1);
  33.     c->y1 = MIN(a->y1, b->y1);
  34. }
  35.  
  36. window_overlap(a, b)
  37. register Window *a, *b;
  38. {
  39.     return a->x0<=b->x1 && a->x1>=b->x0 && a->y0<=b->y1 && a->y1>=b->y0;
  40. }
  41.  
  42. window_print(str, a)
  43. char *str;
  44. Window *a;
  45. {
  46.     fprintf(stderr,"%s{%d,%d,%d,%d}%d,%d",
  47.     str, a->x0, a->y0, a->x1, a->y1, a->x1-a->x0+1, a->y1-a->y0+1);
  48. }
  49.  
  50. /*----------------------------------------------------------------------*/
  51.  
  52. window_box_intersect(a, b, c)
  53. register Window_box *a, *b, *c;
  54. {
  55.     c->x0 = MAX(a->x0, b->x0);
  56.     c->y0 = MAX(a->y0, b->y0);
  57.     c->x1 = MIN(a->x1, b->x1);
  58.     c->y1 = MIN(a->y1, b->y1);
  59.     window_box_set_size(c);
  60. }
  61.  
  62. window_box_print(str, a)
  63. char *str;
  64. Window_box *a;
  65. {
  66.     fprintf(stderr,"%s{%d,%d,%d,%d}%d,%d",
  67.     str, a->x0, a->y0, a->x1, a->y1, a->nx, a->ny);
  68. }
  69.  
  70. window_box_set_max(a)
  71. register Window_box *a;
  72. {
  73.     a->x1 = a->x0+a->nx-1;
  74.     a->y1 = a->y0+a->ny-1;
  75. }
  76.  
  77. window_box_set_size(a)
  78. register Window_box *a;
  79. {
  80.     a->nx = a->x1-a->x0+1;
  81.     a->ny = a->y1-a->y0+1;
  82. }
  83.